<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

	<table align="right">
		<tr>
			<td>
				<h:commandButton immediate="true"
					onclick="abrirPopup('help_online/help_consultar_vales.seam');" 
					title="Ajuda Online"
					alt="Ajuda Online"
					image="img/help_peq.jpg"/>
			</td>
		</tr>
	</table>

	<h2 class="title"><a href="#">Consultar Vales</a></h2><br/>
	
    <h:form id="consultaValesForm">

	        <h:panelGrid columns="1">
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Tipo de Vale:</ui:define>
	        		<h:selectOneMenu value="#{consultarValesController.parametrosConsulta.idTipoVale}">
	        			<f:selectItems value="#{consultarValesController.listaTiposVale}"/>
	        		</h:selectOneMenu>
	        	</s:decorate>
	        
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Funcionário:</ui:define>
	        		<h:selectOneMenu value="#{consultarValesController.parametrosConsulta.idFuncionario}">
	        			<f:selectItems value="#{consultarValesController.listaFuncionarios}" />
	        		</h:selectOneMenu>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Período:</ui:define>
	        		<rich:calendar value="#{consultarValesController.parametrosConsulta.dataInicioVale}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        		à
	        		<rich:calendar value="#{consultarValesController.parametrosConsulta.dataFimVale}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        	</s:decorate>
	        	
	        </h:panelGrid>
	        
	        <div class="actionButtons">
	            <h:commandButton id="pesq" value="Pesquisar" action="#{consultarValesController.pesquisar}"/>
	        </div>
	        
	        <center>
	        	<h1>RESULTADO</h1>
	        </center>
	        
	        	<rich:dataTable var="_result" value="#{consultarValesController.listaVales}"
	        		rows="10" id="tabelaVales">
	        		
	        		<rich:column>
	        			<f:facet name="header">TIPO DE VALE</f:facet>
	        			<h:outputText value="#{_result.tipoVale.dscTipoVale}"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header">FUNCIONÁRIO</f:facet>
	        			<h:outputText value="#{_result.funcionario.dscNome}"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header">DATA</f:facet>
	        			<h:outputText value="#{_result.dtaVale}">
	        				<s:convertDateTime pattern="dd/MM/yyyy"/>
	        			</h:outputText>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header">VALOR</f:facet>
	        			<h:outputText value="#{_result.vlrVale}" converter="conversorMonetario"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header">OBSERVAÇÃO</f:facet>
	        			<h:outputText value="#{_result.dscObservacao}" />
	        		</rich:column>
	        		
	        		<f:facet name="footer">
			    		<rich:columnGroup>
				    		<rich:column>
								<h:outputText value="VALOR TOTAL: R$ "/>		    		
				    		</rich:column>
				    		<rich:column colspan="4">
								<h:outputText value="#{consultarValesController.valorTotal}"
									converter="conversorMonetario"/>		    		
				    		</rich:column>
			    		</rich:columnGroup>
			    	</f:facet>
			    	
	        	</rich:dataTable>
	        	<rich:datascroller for="tabelaVales"/>
	        	
	        	<h:commandButton action="#{excelExporter.export('consultaValesForm:tabelaVales')}"
	        		rendered="#{consultarValesController.listaVales.size() > 0}" 
	        		value="EXPORTAR EXCEL" />
    </h:form>

 </ui:define>
</ui:composition>
